#ifndef __HDC1080_H
#define __HDC1080_H

#include "main.h"
#include "shell_port.h"


//端口定义
#define HDC1080_SCL_GPIO_PORT 			GPIOD
#define HDC1080_SCL_GPIO_PIN			GPIO_PIN_13
#define HDC1080_SDA_GPIO_PORT 			GPIOD
#define HDC1080_SDA_GPIO_PIN			GPIO_PIN_12
#define HDC1080_I2C_DELAY				100
#define HDC1080_I2C_TIMEOUT				2000




//温湿度数据
typedef struct
{
	float board_temperature;
	float board_humidity;
}HDC_TEMP_HUM;
extern HDC_TEMP_HUM HDC;






//器件地址，函数中已经区分读和写地址(软件i2c和硬件i2c),最后一位为读写标志位
//The I2C address of the HDC1080 is 1000000 (7-bit address)
#define HDC1080_ADDR			0x80


#define HDC1080_TEMPERATURE     0x00
#define HDC1080_HUMIDITY        0x01
#define HDC1080_CONFIG          0x02



#define HDC1080_CONFIG_RST      (1 << 15)
#define HDC1080_CONFIG_HEAT     (1 << 13)
#define HDC1080_CONFIG_MODE     (1 << 12)
#define HDC1080_CONFIG_BATT     (1 << 11)
#define HDC1080_CONFIG_TRES_14  (0 << 10)
#define HDC1080_CONFIG_TRES_11  (1 << 10)
#define HDC1080_CONFIG_HRES_14  (0 << 8)
#define HDC1080_CONFIG_HRES_11  (1 << 8)
#define HDC1080_CONFIG_HRES_8   (1 << 9)

#define HDC1080_SERIAL_ID_FIRST 0xFB
#define HDC1080_SERIAL_ID_MID   0xFC
#define HDC1080_SERIAL_ID_LAST  0xFD
#define HDC1080_MANUFID         0xFE
#define HDC1080_DEVICEID        0xFF





uint8_t HDC1080_Init(void);
uint8_t HDC1080_WriteData(uint16_t MemAddress,uint8_t *data,int size);
uint8_t HDC1080_ReadData(uint16_t MemAddress,uint8_t *buff,int size);
float HDC1080_Get_Temperature(void);
float HDC1080_Get_Humidity(void);
void HDC1080_Data_Update();



#endif
